<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Input</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK参考手册">
<link rel="up" href="reference.html" title="API参考">
<link rel="prev" href="gdk-Threads.html" title="Threads">
<link rel="next" href="gdk-Input-Devices.html" title="Input Devices">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk-Threads.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK参考手册</th>
<td><a accesskey="n" href="gdk-Input-Devices.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk-Input.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk-Input.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk-Input"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-Input.top_of_page"></a>Input</span></h2>
<p>Input — Callbacks on file descriptors</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk-Input.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk/gdk.h&gt;

<a href="../glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>                <a class="link" href="gdk-Input.html#gdk-input-add-full" title="gdk_input_add_full ()">gdk_input_add_full</a>                  (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> source</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition"><span class="type">GdkInputCondition</span></a> condition</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputFunction" title="GdkInputFunction ()"><span class="type">GdkInputFunction</span></a> function</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> destroy</code></em>);
enum                <a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition">GdkInputCondition</a>;
<span class="returnvalue">void</span>                (<a class="link" href="gdk-Input.html#GdkInputFunction" title="GdkInputFunction ()">*GdkInputFunction</a>)                 (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> source</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition"><span class="type">GdkInputCondition</span></a> condition</code></em>);
<span class="returnvalue">void</span>                (<a class="link" href="gdk-Input.html#GdkDestroyNotify" title="GdkDestroyNotify ()">*GdkDestroyNotify</a>)                 (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a href="../glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>                <a class="link" href="gdk-Input.html#gdk-input-add" title="gdk_input_add ()">gdk_input_add</a>                       (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> source</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition"><span class="type">GdkInputCondition</span></a> condition</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputFunction" title="GdkInputFunction ()"><span class="type">GdkInputFunction</span></a> function</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk-Input.html#gdk-input-remove" title="gdk_input_remove ()">gdk_input_remove</a>                    (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> tag</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk-Input.description"></a><h2>Description</h2>
<p>
The functions in this section are used to establish
callbacks when some condition becomes true for
a file descriptor. They are currently just wrappers around
the <a href="../glib/glib-IO-Channels.html">IO Channel</a>
facility.
</p>
</div>
<div class="refsect1">
<a name="gdk-Input.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="gdk-input-add-full"></a><h3>gdk_input_add_full ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>                gdk_input_add_full                  (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> source</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition"><span class="type">GdkInputCondition</span></a> condition</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputFunction" title="GdkInputFunction ()"><span class="type">GdkInputFunction</span></a> function</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> destroy</code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gdk_input_add_full</code> is deprecated and should not be used in newly-written code. Use <a href="../glib/glib-IO-Channels.html#g-io-add-watch-full"><code class="function">g_io_add_watch_full()</code></a> on a <a href="../glib/glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a></p>
</div>
<p>
Establish a callback when a condition becomes true on
a file descriptor.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
<td>a file descriptor.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td>
<td>the condition.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>被调用的函数</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>传递给<em class="parameter"><code>function</code></em>的回调数据</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy</code></em> :</span></p></td>
<td>callback function to call with <em class="parameter"><code>data</code></em> when the input
handler is removed.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a tag that can later be used as an argument to
<a class="link" href="gdk-Input.html#gdk-input-remove" title="gdk_input_remove ()"><code class="function">gdk_input_remove()</code></a>.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GdkInputCondition"></a><h3>enum GdkInputCondition</h3>
<pre class="programlisting">typedef enum
{
  GDK_INPUT_READ       = 1 &lt;&lt; 0,
  GDK_INPUT_WRITE      = 1 &lt;&lt; 1,
  GDK_INPUT_EXCEPTION  = 1 &lt;&lt; 2
} GdkInputCondition;
</pre>
<p>
A set of bit flags used to specify conditions for which
an input callback will be triggered. The three members
of this enumeration correspond to the <em class="parameter"><code>readfds</code></em>,
<em class="parameter"><code>writefds</code></em>, and <em class="parameter"><code>exceptfds</code></em> arguments to the
<code class="function">select</code> system call.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="GDK-INPUT-READ:CAPS"></a><span class="term"><code class="literal">GDK_INPUT_READ</code></span></p></td>
<td>the file descriptor has become available for reading.
(Or, as is standard in Unix, a socket or pipe was closed
at the other end; this is the case if a subsequent read
on the file descriptor returns a count of zero.)
</td>
</tr>
<tr>
<td><p><a name="GDK-INPUT-WRITE:CAPS"></a><span class="term"><code class="literal">GDK_INPUT_WRITE</code></span></p></td>
<td>the file descriptor has become available for writing.
</td>
</tr>
<tr>
<td><p><a name="GDK-INPUT-EXCEPTION:CAPS"></a><span class="term"><code class="literal">GDK_INPUT_EXCEPTION</code></span></p></td>
<td>an exception was raised on the file descriptor.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GdkInputFunction"></a><h3>GdkInputFunction ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GdkInputFunction)                 (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> source</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition"><span class="type">GdkInputCondition</span></a> condition</code></em>);</pre>
<p>
A callback function that will be called when some condition
occurs.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>the user data passed to <a class="link" href="gdk-Input.html#gdk-input-add" title="gdk_input_add ()"><code class="function">gdk_input_add()</code></a> or <a class="link" href="gdk-Input.html#gdk-input-add-full" title="gdk_input_add_full ()"><code class="function">gdk_input_add_full()</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
<td>the source where the condition occurred.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td>
<td>the triggering condition.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GdkDestroyNotify"></a><h3>GdkDestroyNotify ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GdkDestroyNotify)                 (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">GdkDestroyNotify</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
A callback function called when a piece of user data is
no longer being stored by GDK. Will typically free the
structure or object that <em class="parameter"><code>data</code></em> points to.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>the user data.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-input-add"></a><h3>gdk_input_add ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a>                gdk_input_add                       (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> source</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputCondition" title="enum GdkInputCondition"><span class="type">GdkInputCondition</span></a> condition</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-Input.html#GdkInputFunction" title="GdkInputFunction ()"><span class="type">GdkInputFunction</span></a> function</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gdk_input_add</code> is deprecated and should not be used in newly-written code. Use <a href="../glib/glib-IO-Channels.html#g-io-add-watch"><code class="function">g_io_add_watch()</code></a> on a <a href="../glib/glib-IO-Channels.html#GIOChannel"><span class="type">GIOChannel</span></a></p>
</div>
<p>
Establish a callback when a condition becomes true on
a file descriptor.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
<td>a file descriptor.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td>
<td>the condition.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>被调用的函数</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>传递给<em class="parameter"><code>function</code></em>的回调数据</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a tag that can later be used as an argument to
<a class="link" href="gdk-Input.html#gdk-input-remove" title="gdk_input_remove ()"><code class="function">gdk_input_remove()</code></a>.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-input-remove"></a><h3>gdk_input_remove ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_input_remove                    (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> tag</code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gdk_input_remove</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Remove a callback added with <a class="link" href="gdk-Input.html#gdk-input-add" title="gdk_input_add ()"><code class="function">gdk_input_add()</code></a> or
<a class="link" href="gdk-Input.html#gdk-input-add-full" title="gdk_input_add_full ()"><code class="function">gdk_input_add_full()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
<td>the tag returned when the callback was set up.</td>
</tr></tbody>
</table></div>
</div>
</div>
<div class="refsect1">
<a name="gdk-Input.see-also"></a><h2>See Also</h2>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a href="../glib/glib-The-Main-Event-Loop.html">GLib Main Loop</a></span></p></td>
<td><p>The main loop in which input callbacks run.</p></td>
</tr>
<tr>
<td><p><span class="term"><a href="../glib/glib-IO-Channels.html">IO Channels</a></span></p></td>
<td><p>A newer and more flexible way of doing IO
callbacks.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>